*******************************************************************************************************************************
*******************************************************************************************************************************
* Documentation for Reproduction of
* Denny 2013 TESS Survey Experiment
* TESS Race Discrimination Meta-Analysis
* Stata version 15
* Data available here: http://www.tessexperiments.org/data/denny366.html
*******************************************************************************************************************************
*******************************************************************************************************************************

* use "TESS3 143 Denny_Client.dta", clear
set more off

*******************************************************************************************************************************
*** Racial groups
*******************************************************************************************************************************

tab PPETHM
gen whiteR = PPETHM
recode whiteR (2/5=0)
tab PPETHM whiteR
gen blackR = PPETHM
recode blackR (1 3/5=0) (2=1)
tab PPETHM blackR
gen hispnR = PPETHM
recode hispnR (1/3 5=0) (4=1)
tab PPETHM hispnR

*******************************************************************************************************************************
*** Treatments
*******************************************************************************************************************************

gen whitefemaleT = 0
replace whitefemaleT = 1 if XTESS143==1 | XTESS143==5 | XTESS143==9 | XTESS143==13 | XTESS143==17 | XTESS143==19
gen blackfemaleT = 0
replace blackfemaleT = 1 if XTESS143==2 | XTESS143==6 | XTESS143==10 | XTESS143==14 | XTESS143==18 | XTESS143==20
gen hispanicfemaleT = 0
replace hispanicfemaleT = 1 if XTESS143==3 | XTESS143==7 | XTESS143==11 | XTESS143==15
gen asianfemaleT = 0
replace asianfemaleT = 1 if XTESS143==4 | XTESS143==8 | XTESS143==12 | XTESS143==16
gen whitemaleT = 0
replace whitemaleT = 1 if XTESS143==21
gen blackmaleT = 0
replace blackmaleT = 1 if XTESS143==22
gen hispanicmaleT = 0
replace hispanicmaleT = 1 if XTESS143==23
gen asianmaleT = 0
replace asianmaleT = 1 if XTESS143==24

tab XTESS143 whitefemaleT
tab XTESS143 blackfemaleT
tab XTESS143 hispanicfemaleT
tab XTESS143 asianfemaleT
tab XTESS143 whitemaleT
tab XTESS143 blackmaleT
tab XTESS143 hispanicmaleT
tab XTESS143 asianmaleT

gen blackT = 0
replace blackT = 1 if blackfemaleT==1 | blackmaleT==1
tab XTESS143 blackT

gen whiteT = 0
replace whiteT = 1 if whitefemaleT==1 | whitemaleT==1
tab XTESS143 whiteT

gen femaleT = 0
replace femaleT = 1 if whitefemaleT==1 | blackfemaleT==1 | hispanicfemaleT==1 | asianfemaleT==1
tab XTESS143 femaleT

gen nokidsT = 0
replace nokidsT = 1 if XTESS143==1 | XTESS143==2 | XTESS143==3 | XTESS143==4
gen kidsT = 0
replace kidsT = 1 if XTESS143==5 | XTESS143==6 | XTESS143==7 | XTESS143==8 | XTESS143==21 | XTESS143==22 | XTESS143==23 | XTESS143==24
gen kidsnotinvT = 0
replace kidsnotinvT = 1 if XTESS143==9 | XTESS143==10 | XTESS143==11 | XTESS143==12
gen kidsinvT = 0
replace kidsinvT = 1 if XTESS143==13 | XTESS143==14 | XTESS143==15 | XTESS143==16
gen kidsfewcareT = 0
replace kidsfewcareT = 1 if XTESS143==17 | XTESS143==18
gen kidsmanycareT = 0
replace kidsmanycareT = 1 if XTESS143==19 | XTESS143==20

tab XTESS143 nokidsT
tab XTESS143 kidsT
tab XTESS143 kidsnotinvT
tab XTESS143 kidsinvT
tab XTESS143 kidsfewcareT
tab XTESS143 kidsmanycareT

*******************************************************************************************************************************
*** Outcome variables
*******************************************************************************************************************************

tab1 Q1 Q2 Q3 Q4 Q5 Q6
tab1 Q1 Q2 Q3 Q4 Q5 Q6, nol
recode Q1 Q2 Q3 Q4 Q5 Q6 (-1=.)
alpha Q1 Q2 Q3 Q4 Q5 Q6, item

alpha Q1 Q2 Q3, item std min(2) gen(characterALPHA)
egen characterALPHA_std = std(characterALPHA)

alpha Q4 Q5 Q6, item std min(2) gen(hireALPHA)
egen hireALPHA_std = std(hireALPHA)

alpha Q1 Q2 Q3 Q4 Q5 Q6, item std min(3) gen(ALPHA)

sum ALPHA if whiteR==1
di r(sd)
gen ov_white_std = ALPHA/r(sd) if whiteR==1

sum ALPHA if blackR==1
di r(sd)
gen ov_black_std = ALPHA/r(sd) if blackR==1

sum ALPHA if hispnR==1
di r(sd)
gen ov_hispn_std = ALPHA/r(sd) if hispnR==1

*******************************************************************************************************************************
*** Racial manipulation check
*******************************************************************************************************************************

// No racial manipulation check

*******************************************************************************************************************************
*** Main regressions [Unweighted]
*******************************************************************************************************************************

reg ov_white_std blackT femaleT nokidsT kidsnotinvT kidsinvT kidsfewcareT kidsmanycareT if (whiteT==1 | blackT==1) & whiteR==1
reg ov_black_std blackT femaleT nokidsT kidsnotinvT kidsinvT kidsfewcareT kidsmanycareT if (whiteT==1 | blackT==1) & blackR==1
reg ov_hispn_std blackT femaleT nokidsT kidsnotinvT kidsinvT kidsfewcareT kidsmanycareT if (whiteT==1 | blackT==1) & hispnR==1
